﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace NotAClue.ComponentModel.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class AppSettingAttribute : Attribute
    {
        // this property is required to work with "AllowMultiple = true" ref David Ebbo
        // As implemented, this identifier is merely the Type of the attribute. However, 
        // it is intended that the unique identifier be used to identify two 
        // attributes of the same type.
        public override object TypeId { get { return this; } }

        public String AppSetting { get; private set; }
        public String AppSettingValue
        {
            get
            {
                return ConfigurationManager.AppSettings[AppSetting];
            }
        }

        public AppSettingAttribute()
        {
        }

        public AppSettingAttribute(String appSetting)
        {
            AppSetting = appSetting;
        }
    }
}